/*
 * Copyright 2017-8-30 13:56:25 The JA-SIG Collaborative. All rights reserved.
 * distributed with thi file and available online at
 */
package com.lap.scp.admin.core.impl;

import java.util.Collections;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.lap.scd.commons.core.exception.ManagerException;
import com.lap.scd.commons.page.Page;
import com.lap.scp.admin.core.ResourcesManager;
import com.lap.scp.admin.dal.ResourcesDAO;
import com.lap.scp.admin.domain.ResourcesDO;
import com.lap.scp.admin.query.ResourcesQueryDO;

/**
 * <pre>
 * 资源管理
 * </pre>
 * 
 * @author 系统自动生成 Exp
 * @Date 2017-8-30 13:56:25
 * @since 1.0
 */
@Service("resourcesManager")
public class DefaultResourcesManager implements ResourcesManager {

	@Resource
	private ResourcesDAO resourcesDAO;

	@Override
	public int countByPid(int pid) throws ManagerException {
		return resourcesDAO.countByPid(pid);
	}

	@Override
	public int deleteById(int resourcesId) throws ManagerException {
		return resourcesDAO.deleteById(resourcesId);
	}

	@Override
	public void insertResources(ResourcesDO resourcesDO) throws ManagerException {
		resourcesDAO.insertResources(resourcesDO);
	}

	@Override
	public ResourcesDO queryById(int resourcesId) throws ManagerException {
		return resourcesDAO.queryById(resourcesId);
	}

	@Override
	public List<ResourcesDO> queryPage(Page page, ResourcesQueryDO queryDO) throws ManagerException {
		int count = resourcesDAO.countPage(queryDO);
		if (count <= 0) {
			return Collections.emptyList();
		} else {
			page.setTotalItem(count);
			return resourcesDAO.queryPage(page, queryDO);
		}
	}

	@Override
	public int updateResources(ResourcesDO resourcesDO) throws ManagerException {
		return resourcesDAO.updateResources(resourcesDO);
	}

	@Override
	public List<String> queryByUserId(int userId) throws ManagerException {
		return resourcesDAO.queryByUserId(userId);
	}

	@Override
	public List<ResourcesDO> queryList(ResourcesQueryDO queryDO) throws ManagerException {
		return resourcesDAO.queryList(queryDO);
	}

	@Override
	public List<String> queryUrlList() throws ManagerException {
		return resourcesDAO.queryUrlList();
	}

}
